package com.qitianyong.selfclass;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by qitainyong on 2017/3/22.
 */

public class FileManager {

    public static void saveData2jpg(byte[] data, String path){
        FileOutputStream fileW = null;
        try {

            fileW = new FileOutputStream(path);
            fileW.write(data);
            fileW.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // 读取本地图片文件
    public static Bitmap getLocalBitmap(String url){
        try {
            FileInputStream fis = new FileInputStream(url);
            return BitmapFactory.decodeStream(fis);
        } catch (FileNotFoundException e) {

            e.printStackTrace();
            return null;
        }
    }
}
